home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Demos
/
A.D. Software
/
OOFILE
/
Buildable, limited OOFILE
/
samples
/
ooftst18.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-23
|
2KB
|
73 lines
// Copyright 1994 A.D. Software. All Rights Reserved
// OOFTEST18
// This sample tests the wildcard searches.
// Simple stream I/O is used to interact with the user.
// NOTE the odd sizes in the fields below are to help trap alignment issues
#include "oofile.hpp"
#include "ooftst01.inc"
int main()
{
cout << "OOFILE Validation Suite - Test 18\n"
<< "Test of wildcard searching\n";
dbConnect_ctree theDB;
dbPeople People;
theDB.useSeparateFiles(); // note the blank connection names!
// this test creates People.dat, People.idx & Blobs
#ifdef _Macintosh
// this feature only on the Mac at present
#define kExistsName ":test01:People.dat"
#define kDatabaseName "test01"
#else
#define kExistsName "People.dat"
#define kDatabaseName ""
#endif
if (dbConnect::fileExists(kExistsName))
theDB.openConnection(kDatabaseName);
else {
theDB.newConnection(kDatabaseName);
People.AddTestData();
}
dbView justNames(People);
justNames << People.LastName << People.OtherNames;
People.setSortOrder(People.LastName);
People.search(People.LastName=="*");
cout << endl << "Testing pathological case '*' - should be all records" << endl
<< justNames << endl;
cout << "Retrieving T*r: " << People[People.LastName=="T*r"].LastName << endl;
People.search(People.LastName=="D??t");
cout << "Listing two D??t records: " << endl << justNames << endl;
People.search(People.LastName=="?mith");
cout << "Listing leading '?' with ?mith: " << endl << justNames << endl;
People.search(People.LastName=="De*");
cout << "Listing trailing single '*' with De*: " << endl << justNames << endl;
People.search(People.LastName!="De*");
cout << "Testing not-equals wildcard with !De*: " << endl << justNames << endl;
People.search(People.LastName.startsWith("D*n"));
cout << "Listing startsWith D*n: " << endl << justNames << endl;
People.search(People.LastName.startsWith("D*n*"));
cout << "Listing startsWith D*n*: " << endl << justNames << endl;
cout << "Test Completed" << endl;
return EXIT_SUCCESS;
}